package com.yuetong.quotation.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yuetong.common.annotation.Log;
import com.yuetong.common.core.controller.BaseController;
import com.yuetong.common.core.domain.AjaxResult;
import com.yuetong.common.enums.BusinessType;
import com.yuetong.quotation.domain.YtQuotationDetail;
import com.yuetong.quotation.service.IYtQuotationDetailService;
import com.yuetong.common.utils.poi.ExcelUtil;
import com.yuetong.common.core.page.TableDataInfo;

/**
 * 报价详情明细Controller
 * 
 * @author  卓晓君
 * @date 2025-02-11
 */
@RestController
@RequestMapping("/quotation/detail")
public class YtQuotationDetailController extends BaseController
{
    @Autowired
    private IYtQuotationDetailService ytQuotationDetailService;

    /**
     * 查询报价详情明细列表
     */
    @PreAuthorize("@ss.hasPermi('quotation:detail:list')")
    @GetMapping("/list")
    public TableDataInfo list(YtQuotationDetail ytQuotationDetail)
    {
        startPage();
        List<YtQuotationDetail> list = ytQuotationDetailService.selectYtQuotationDetailList(ytQuotationDetail);
        return getDataTable(list);
    }

    /**
     * 导出报价详情明细列表
     */
    @PreAuthorize("@ss.hasPermi('quotation:detail:export')")
    @Log(title = "报价详情明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YtQuotationDetail ytQuotationDetail)
    {
        List<YtQuotationDetail> list = ytQuotationDetailService.selectYtQuotationDetailList(ytQuotationDetail);
        ExcelUtil<YtQuotationDetail> util = new ExcelUtil<YtQuotationDetail>(YtQuotationDetail.class);
        util.exportExcel(response, list, "报价详情明细数据");
    }

    /**
     * 获取报价详情明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('quotation:detail:query')")
    @GetMapping(value = "/{detailId}")
    public AjaxResult getInfo(@PathVariable("detailId") Long detailId)
    {
        return success(ytQuotationDetailService.selectYtQuotationDetailByDetailId(detailId));
    }

    /**
     * 新增报价详情明细
     */
    @PreAuthorize("@ss.hasPermi('quotation:detail:add')")
    @Log(title = "报价详情明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YtQuotationDetail ytQuotationDetail)
    {
        return toAjax(ytQuotationDetailService.insertYtQuotationDetail(ytQuotationDetail));
    }

    /**
     * 修改报价详情明细
     */
    @PreAuthorize("@ss.hasPermi('quotation:detail:edit')")
    @Log(title = "报价详情明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YtQuotationDetail ytQuotationDetail)
    {
        return toAjax(ytQuotationDetailService.updateYtQuotationDetail(ytQuotationDetail));
    }

    /**
     * 删除报价详情明细
     */
    @PreAuthorize("@ss.hasPermi('quotation:detail:remove')")
    @Log(title = "报价详情明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{detailIds}")
    public AjaxResult remove(@PathVariable Long[] detailIds)
    {
        return toAjax(ytQuotationDetailService.deleteYtQuotationDetailByDetailIds(detailIds));
    }
}
